  const gulp = require('gulp'),
      clean = require("gulp-clean"),
      runSequence = require('run-sequence'),
      browserSync = require('browser-sync').create(),
      shell = require('gulp-shell');

const reload = browserSync.reload;


gulp.task('clean', function() {
     return gulp.src(['build'], { read: false }).pipe(clean());
 });
//.pipe(reload({stream: true}))


 gulp.task('watch', function() {
     gulp.watch("./app/**/*", ['gitbook','reload']);

 });


gulp.task('server', function() {
    browserSync.init({
        server:{
           baseDir:"./build",
        },
        port:8089,
    });
});

gulp.task("reload",()=>{
    reload();
})



 gulp.task('gitbook',  shell.task([
  'gitbook build ./app ./build'
]));

 gulp.task('build', function() {
    runSequence("clean","gitbook","watch","server");
 });
